---
title: Detect form fields
summary: Reports whether a PDF carries fillable AcroForm fields.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-17
library: PdfAPI.Core
reference_type: package
operation_id: OP-06
trigger: PdfClientService.HasFormFields(byte[]) invoked
---

# Detect form fields

This operation opens the PDF with iTextSharp and inspects its AcroForm to determine whether it carries interactive form fields.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-06 |
| **Trigger** | Caller invokes `HasFormFields(byte[] file)` |
| **Inputs** | PDF bytes |
| **Outputs** | `true` / `false` |
| **Primary components** | `PdfAPI.Core.PdfClientService.HasFormFields` |
| **Entry point** | `PdfAPI.Core\Services\PdfClientService.cs` |

## Steps

1. Run [Validate PDF bytes](op-01-validate-pdf-bytes.md) to guard the input. ([BR-01](../business-rules.md#br-01-pdf-signature-validation), [BR-02](../business-rules.md#br-02-null-bytes-are-never-a-pdf), [BR-03](../business-rules.md#br-03-invalid-pdf-input-aborts-with-pdfexception))
2. Open an iTextSharp `PdfReader` over the bytes.
3. Return `false` when `reader.AcroForm` is null. ([BR-10](../business-rules.md#br-10-form-field-detection-requires-acroform))
4. Otherwise return whether `reader.AcroFields.Fields.Count > 0`. ([BR-10](../business-rules.md#br-10-form-field-detection-requires-acroform))

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start(["HasFormFields(bytes)"]) --> Guard["OP-01: ValidatePdf"]
	Guard --> Open["Open PdfReader"]
	Open --> Form{reader.AcroForm null?}
	Form -->|Yes| False([Return false])
	Form -->|No| Count{AcroFields.Fields.Count > 0?}
	Count -->|Yes| True([Return true])
	Count -->|No| False2([Return false])
```

## Failure and edge-case behavior
- A PDF with an AcroForm dictionary but zero fields still reports `false`.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [Security and authorization](../security-authorization.md)

## Sources
- `PdfAPI.Core\Services\PdfClientService.cs`
